<!DOCTYPE html>
<html lang="en">

<head>
    <#include "/xhc/admin/components/meta.html" />
    <title>出出帮火车奇妙世界 ${metaTitleSuffix!}</title>
    <#include "/xhc/admin/components/stylesheets.html" />
    <link rel="stylesheet" href="/xhc/admin/components/stylesheets/index.css?v=2">
</head>

<body>
    <div id="app">
        <div class="logo">
            <!-- <img src="/xhc/app/assets/img/logo.png" class="am-img-responsive" /> -->
        </div>
        <div class="login-form" style="margin: 0 auto; width: 50%; min-width: 700px;">
            <div class="login-form-field">
                <div class="login-form-field-icon">
                    <img src="/xhc/admin/assets/img/icon-user.png" class="am-img-responsive" />
                </div>
                    <div class="login-form-field-input">
                        <input type="text" v-model="account" placeholder="邮箱 / 手机号" />
                    </div>
                </div>
                <div class="login-form-field">
                    <div class="login-form-field-icon">
                        <img src="/xhc/admin/assets/img/icon-pwd.png" class="am-img-responsive" />
                </div>
                        <div class="login-form-field-input">
                            <input type="password" v-model="password" placeholder="密码" @keyup.enter="login" />
                        </div>
                    </div>
                    <div class="login-form-submit">
                        <button class="am-btn theme-background-color1" @click="login">登录</button>
                    </div>
                </div>
                <footer style="width: 50%; min-width: 700px; height: 60px; padding: 20px 3rem; margin: 0 auto;">
                    <p>由 <a href="http://www.zhen-yee.com/" title="蓁奕科技" target="_blank" style="color: rgb(14, 144, 210);">蓁奕科技</a> 提供技术支持 CopyRight©2018 Zhenyi Tech Inc.</p>
                </footer>
            </div>
            <#include "/xhc/admin/components/scripts.html" />
            <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9/crypto-js.min.js"></script> -->
            <script src="//res.zhen-yee.com/assert/crypto-js.3.1.9.min.js"></script>
            <script type="text/javascript">
            var app = new Vue({
                el: '#app',
                data() {
                    return {
                        account: '',
                        password: ''
                    }
                },
                mounted: function() {},
                methods: {
                    login() {
                        var self = this;
                        var encoded = self.aesCBC(self.password);
                        var param = Qs.stringify({
                            account: self.account,
                            password: encoded
                        });
                        var layerIndex = layer.open({ type: 2, shadeClose: false });
                        axios({
                                url: '/xhc/web/auth/submit',
                                method: 'post',
                                data: param,
                                headers: {
                                    'Content-Type': 'application/x-www-form-urlencoded'
                                }
                            })
                            .then(function(response) {
                                if (response.data.status == 200) {
                                    var url = "/xhc/web/ticket/list"
                                    window.location.href = url;
                                    return;
                                    // msg("登录成功");
                                } else {
                                    layer.open({
                                        content: "登录失败：" + response.data.msg,
                                        skin: 'msg',
                                        time: 5 //2秒后自动关闭
                                    });
                                    console.log(response.data);
                                }
                                layer.close(layerIndex);
                            })
                            .catch(function(error) {
                                layer.open({
                                    content: "登录失败",
                                    skin: 'msg',
                                    time: 5 //2秒后自动关闭
                                });
                                console.log(error);
                                layer.close(layerIndex);
                            });
                    },
                    aesCBC(text) {
                        var aesText = text;
                        var key = CryptoJS.enc.Utf8.parse('${key!}');
                        var iv = CryptoJS.enc.Utf8.parse('RandomInitVector');
                        aesText = CryptoJS.AES.encrypt(text, key, {
                            iv: iv,
                            mode: CryptoJS.mode.CBC,
                            padding: CryptoJS.pad.Pkcs7
                        }).toString();
                        return aesText;
                    }
                }
            })
            </script>
            <script>
            // wx.ready(function() {
            //     initWXShare()
            // })
            </script>
</body>

</html>